﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PMKB_Repository;
using System.Web.Mvc;
using KVP;

namespace PMKB_Web.Models
{
    //TODO: Move this in utility
    static class A
    {
        public static SelectListItem ToSelectListItem<U>(this KVPNew<U, string> k)
        {
            return new SelectListItem() { Text = k.Value, Value = k.Key.ToString() };
        }
    }
    public class LinkAddOrEditMVC : LinkAddOrEdit
    {
        public MultiSelectList TagsMVC
        {
            get
            {

                bool Sel = (base.IDSelectedTags != null && base.IDSelectedTags.Count > 0);
                SelectListItem[] a = new SelectListItem[Tags.Count];
                for (int i = 0; i < Tags.Count; i++)
                {
                    a[i] = Tags[i].ToSelectListItem();
                    if (Sel)
                    {
                        a[i].Selected = base.IDSelectedTags.Contains(long.Parse(a[i].Value));
                    }

                }

                return new MultiSelectList(a, "Value", "Text", base.IDSelectedTags);

            }
        }

       
    }
}